package com.its.us.web.config.authorization;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @Author: master
 * @Date: 2020/10/28 14:06
 * @Version: 1.0
 */
//@Configuration
public class JwtTokenStoreConfig {

    private final String JWT_TOKEN_KEY = "jwt_token";

    @Bean
    public TokenStore jwtTokenStore(){
        return new JwtTokenStore(jwtAccessTokenConverter());
    }

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        // 设置jwt密钥
        jwtAccessTokenConverter.setSigningKey(JWT_TOKEN_KEY);
        return jwtAccessTokenConverter;
    }
}
